# Contributor: Bradley J Chambers <brad.chambers@gmail.com>
# Maintainer: Bradley J Chambers <brad.chambers@gmail.com>
pkgname=pdal
pkgver=2.1.0
pkgrel=0
pkgdesc="PDAL is a C++ BSD library for translating and manipulating point cloud data."
options="!check" # 1 test fails
url="https://pdal.io"
arch="all !armhf !armv7 !s390x !mips !mips64"
# dependency laz-perf-dev missing on armhf, armv7, s390x, mips, mips64
# dependency cpd-dev missing on armv7, mips, mips64
# dependency gdal-dev missing on s390x, mips, mips64
license="BSD-2-Clause"
depends="nitro python3 py3-numpy>=1.14.3-r1"
makedepends="
	cmake
	eigen-dev
	nitro-dev
	gdal-dev
	laz-perf-dev
	libgeotiff-dev
	libxml2-dev
	python3-dev
	py3-numpy-dev
	hdf5-dev
	cpd-dev
	fgt-dev
	sqlite-dev
	postgresql-dev
	curl-dev
	laszip-dev
	linux-headers
	libexecinfo-dev
	zstd-dev
	"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/PDAL/PDAL/releases/download/$pkgver/PDAL-$pkgver-src.tar.gz"
builddir="$srcdir/PDAL-$pkgver-src"

build() {
	cmake -B build \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DBUILD_PLUGIN_PYTHON=ON \
		-DBUILD_PLUGIN_CPD=ON \
		-DBUILD_PLUGIN_NITF=ON \
		-DBUILD_PLUGIN_ICEBRIDGE=ON \
		-DBUILD_PLUGIN_PGPOINTCLOUD=ON \
		-DBUILD_PGPOINTCLOUD_TESTS=OFF \
		-DBUILD_PLUGIN_SQLITE=ON \
		-DWITH_LASZIP=ON \
		-DWITH_LAZPERF=ON \
		-DWITH_TESTS=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --build build --target install
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

sha512sums="273e43bc02039ef56e22d6496d74c645c947dec7961024f419232b3f70ad5de030d5ee9fb74f44649016da67ff39179b06fa0d85f17a3b7db5fcce3cd0e35ac5  pdal-2.1.0.tar.gz"
